import cgrdf.*
import org.grails.plugins.springsecurity.service.AuthenticateService

class BootStrap {
    def authenticateService = new AuthenticateService()

    def init = { servletContext ->
        
    // Create a role for the demo application
		new Role(authority: 'ROLE_ADMIN_USER', description: '系统管理员').save()
        new Role(authority: 'ROLE_USER', description: '普通用户').save()

		println Role.findAll()

		// Create an admin user, and add the admin user role
		def user = new User(
                username: 'administrator',
                passwd: authenticateService.passwordEncoder("123456"),
                enabled:true,
                email:"bruce.lin.chn@gmail.com",
                emailShow:true,
                userRealName:"bruce.lin.chn",
                pass:"123456",
                gender:"Male"       
        )

		user.addToAuthorities(Role.findByAuthority("ROLE_ADMIN_USER"))
		user.save()

        println User.findAll()

        //new Requestmap(url:"/*/**",  configAttribute:"ROLE_ADMIN_USER").save()
    }
    def destroy = {
    }
}
